<template>
    <el-card class="box-card">
        <el-col :span="24" class="toolbar">
            <el-form :inline="true" class="demo-form-inline" :model="searchStockForm">
                <el-form-item>
                    <el-input v-model="searchStockForm.product_name" placeholder="商品名称"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-input v-model="searchStockForm.product_code" placeholder="条码/编号"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-input v-model="searchStockForm.product_owner" placeholder="货主"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-input v-model="searchStockForm.city_name" placeholder="城市名"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-input v-model="searchStockForm.inventory_from" placeholder="库存数量从"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-input v-model="searchStockForm.inventory_to" placeholder="库存数量到"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-select v-model="searchStockForm.status">
                        <el-option value="all" label="全部" selected></el-option>
                        <el-option value="on" label="已上架"></el-option>
                        <el-option value="off" label="已下架"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-button>查询</el-button>
                </el-form-item>
            </el-form>
        </el-col>
        <el-table :data="stockItemsData" style="width: 100%;" border>
            <el-table-column prop="product_name" label="商品名"></el-table-column>
            <el-table-column prop="product_status" label="上下架状态"></el-table-column>
            <el-table-column :show-overflow-tooltip=true prop="product_code" label="条码/编号"></el-table-column>
            <el-table-column :show-overflow-tooltip=true prop="product_owner" label="货主"></el-table-column>
            <el-table-column :show-overflow-tooltip=true prop="market_center" label="营销中心"></el-table-column>
            <el-table-column :show-overflow-tooltip=true prop="city_name" label="城市名"></el-table-column>
            <el-table-column :show-overflow-tooltip=true prop="inventory_num" label="库存数量"></el-table-column>
            <el-table-column label="操作" inline-template>
                <template>
                    <el-button-group>
                        <el-button type="primary" size="mini" title="加入首页轮播" class="el-icon-plus" @click="addHomeBanner"></el-button>
                        <el-button type="primary" size="mini" title="加入首页推荐" class="el-icon-plus" @click="addHomeRecommend"></el-button>
                        <el-button type="primary" size="mini" title="调整库存" class="fa fa-exchange" @click="editStockItemsNum"></el-button>
                        <el-button type="primary" size="mini" title="编辑库存项" class="el-icon-edit" @click="editStockItems"></el-button>
                    </el-button-group>

                </template>
            </el-table-column>
        </el-table>
        <!--分页-->
        <el-col :span="24" class="toolPage">
            <el-pagination :current-page="page.current" :page-sizes="[10, 20, 50, 100]" :page-size="page.size" layout="total, sizes, prev, pager, next, jumper"
                :total="page.total" style="float:right" @size-change="handleSizeChange" @current-change="handlePageChange">
                </el-pagination>
        </el-col>
    </el-card>
</template>
<script>
    export default {
        data() {
            return {
                searchStockForm: {
                    product_name: '',
                    product_code: '',
                    product_owner: '',
                    city_name: '',
                    inventory_from: '',
                    inventory_to: '',
                    status: ''
                },
                stockItemsData: [
                    {
                        product_name: '山东红富士苹果',
                        product_status: '已上架',
                        product_code: '900 等级: 一级, 包装: 箱装, 和 质量包文本: 红度80',
                        product_owner: '金龙贸易111111111222222333333444444甜度太次了过 欧冠苹果个过过里古过一股覅阔过 kjggkhg',
                        market_center: '上海配销中心',
                        city_name: '河南省信阳市',
                        inventory_num: '123456'
                    }
                ],
                page: {
                    total: 0,
                    current: 1,
                    size: 10,
                },
            }
        },
        methods: {
            handleSizeChange(size) {
                this.page.size = size
                // this.loadGridData()
            },
            handlePageChange(current) {
                this.page.current = current
                // this.loadGridData()
            },
            addHomeBanner(row) {
                this.$router.push(`/home_banners/${row.id}/edit`);
            },
            addHomeRecommend(row) {
                this.$router.push(`/home_banners/${row.id}/edit`);
            },
            editStockItemsNum(row) {
                this.$router.push(`/stock_items/${row.id}/edit`);
            },
            editStockItems(row) {
                this.$router.push(`/products/${row.id}/edit`);
            }
        }
    }

</script>